﻿using Coldairarrow.Business.Base_leasesystem_employee;
using Coldairarrow.Entity.Base_leasesystem_employee;
using Coldairarrow.IBusiness;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_leasesystem_employee
{
    /// <summary>
    /// 出租人管理控制器
    /// </summary>
    [Route("/Base_leasesystem_employee/[controller]/[action]")]
    [OpenApiTag("出租人管理控制器")]
    public class leasesystem_employeeController : BaseApiController
    {
        #region DI

        public leasesystem_employeeController(Ileasesystem_employeeBusiness leasesystem_employeeBus, IOperator @operator)
        {
            _leasesystem_employeeBus = leasesystem_employeeBus;
            _operator = @operator;
        }

        Ileasesystem_employeeBusiness _leasesystem_employeeBus { get; }
        readonly IOperator _operator;

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<leasesystem_employee>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_employeeBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<leasesystem_employee> GetTheData(IdInputDTO input)
        {
            return await _leasesystem_employeeBus.GetTheDataAsync(input.id);
        }

        public object GetHeightSearch(PageInput<ConditionDTO> input)
        {
            return _leasesystem_employeeBus.GetHeightSearch(input);
        }
        /// <summary>
        /// 根据出租人id 查询本人所有车辆信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetEmpCar(IdInputDTO input)
        {
            return await _leasesystem_employeeBus.GetEmpCar(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(leasesystem_employee data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _leasesystem_employeeBus.AddDataAsync(data,_operator.UserId);
            }
            else
            {
                await _leasesystem_employeeBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        [ApiPermission("employee.Delete")]
        public async Task DeleteData(List<string> ids)
        {
            await _leasesystem_employeeBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 出租人认证   添加签约信息及修改出租人认证状态
        /// </summary>
        /// <param name="EID">出租人id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task AuthenEmp(List<string> EID)
        {
            await _leasesystem_employeeBus.AuthenEmp(EID,_operator.UserId);
        }
        #endregion
    }
}